import QtQuick

Item {
    function getRoleList(obj){
        var callBack=obj.callBack||(()=>{})
        var xhr=new XMLHttpRequest()
        xhr.onreadystatechange=function(){
            if(xhr.readyState===XMLHttpRequest.DONE){
                if(xhr.status===200){
                    var res=JSON.parse(xhr.responseText)

                    res=res.map(obj=>{
                                return {
                                    roleId:obj.roleId,
                                        roleName:obj.roleName
                                    }
                                })
                    callBack(res)
                }else{
                    console.log("角色列表获取失败："+xhr.status)
                }
            }
        }
        xhr.open("GET","http://localhost:5241/api/Role/List",true)
        xhr.send()
    }
}

